#函数的定义
# def 函数名 ([参数列表]):
#     ['''文档字符串''']
#     函数体
#     [return 函数]

def show_weather():
    print("*"*13)
    print("日期：2月7日")
    print("温度：20~27℃")
    print("空气状态：优良")
    print("*"*13)
show_weather()


#函数的调用
def modify_weather(today,temp,air_quality):
    print("*"*13)
    print(f"日期{today}")
    print(f"温度：{temp}")
    print(f"空气状态：{air_quality}")
    print("*"*13)
modify_weather("7月21日","17~21℃","良")



#函数的参数传递
#位置参数传递
def nan(num_one,num_two):
    print(num_one)
    print(num_two)
    print(num_one /num_two)
nan(2,7)



#关键字参数传递
def nan2(name,age,address):
    print(f'姓名：{name}')
    print(f'年龄：{age}')
    print(f'地址：{address}')
nan2(name="黄楠",age="19",address="南宁")


#默认参数传递
def nan3(ip,age=43):
    print(f"受邀嘉宾：{ip}")
    print(f"年龄：{age}")
    print(f"年度内地最佳男歌手")
nan3('薛之谦')
nan3(ip="薛之谦",age="45")


#参数打包传递
def nan4(*args):
    print(args)
nan4(1,2,3,4,5,6,)

def nan5(**kwargs):
    print(kwargs)
nan5(a=1,b=2,c=3)


#参数解包传递
def nan6(a,b,c,d,e):
    print(a,b,c,d,e)
nums = (11,22,33,44,55)
nan6(*nums)
nums = {"a":11,"b":22,"c":33,"d":44,"e":55}
nan6(**nums)


#变量作用域
#局部变量
def var():
    name = '欲说还休欲说还休，却道天凉好个秋'
    print(name)
# var()
# print(name)

#全局变量
var1 = 10
def var2():
    print(var1)
var2()
print(var1)

def var3():
    global var1
    var1+=10
    print(var1)
var3()



#函数的特殊形式
#匿名函数
area = lambda  a,h:(a*h)*0.5
print(area(2,7))

#递归函数
def var4(num):
    if num ==1:
        return  1
    else:
        return num *var4(num-1)
result = var4(5)
print(f"5的阶乘为{result}")


#常见的内置函数
#abs（）函数
print(abs(-5))
print(abs(3.14))
print(abs(8+3j))

#ord（）函数
print(ord('a'))
print(ord('A'))

#chr（）函数
print(chr(97))
print(chr(65))


































#
#
# #学习通第五次作业
# #第一题
# string = 'skdaskerkjsalkj'
# count_dict = {}
# for char in string:
#     if char in count_dict:
#         count_dict[char] += 1
#     else:
#         count_dict[char] = 1
# print(count_dict)
#
# #第二题
# li_one = [1,2,1,2,3,5,4,3,5,7,4,7,8]
# result = list(set(li_one))
# print(result)



